{% extends 'ForumBundle:Default:template_forum.html.twig' %}

{% block title %}
    {{ topic.getNom_topic }}
    {% if currentPage > 1 %}
        - Page {{ currentPage }}
    {% endif %}
    - Forum des Laboratoires Ingésup
{% endblock %}

{% block stylesheets %}
    <link href="{{ asset('bundles/forum/css/reset.css') }}" rel="stylesheet" type="text/css" />
    <link href="{{ asset('bundles/forum/css/global.css') }}" rel="stylesheet" type="text/css" />
{% endblock %}


{% block body %}
{{ titleForUrl }} <br/><br/>
Catégorie : 
{% for cat in categories %}
    {{ cat.getNom_categorie }} > 
{% endfor %}
    
<h2>Topic Name : {{ topic.getNom_topic }}</h2>
<br/>
Page : {{ currentPage }}
<table class="forum_list">


{% set messages = topic.getMessages %}

{% set begin = (currentPage - 1) * eltsPerPage %}
{% if nbElts < (currentPage) * eltsPerPage - 1%}
    {% set end = nbElts - 1 %}
{% else %}
    {% set end = (currentPage) * eltsPerPage - 1 %}
{% endif %}
    
{% for i in begin..end %}

    <tr id="m{{ messages[i].getId_message }}">
        <td class="message_date">{{ messages[i].getDate_message|date("d/m/Y, H\\hi") }}</td>
        <td class="message_number" ><a href="#m{{ messages[i].getId_message }}">#{{ i + 1 }}</a></td>
    <tr>
        <td class="message_author">
            {% set author = messages[i].getMembre %}
            <span class="author_pseudo">{{ author.getPseudo }}</span>
            <img class="author_avatar" src="{{ asset( 'bundles/forum/images/avatars/' ~ author.getAvatar ) }}" title="{{ author.getPseudo }}" alt="{{ author.getPseudo }}"/>
            <span>Inscription : {{ author.getDate|date("d/m/Y") }}</span>
            <span>Messages : {{ author.getMessages|length }}</span>

        </td>
        <td class="message">{{ messages[i].getContenu_message }}</td>
    </tr>

{% endfor %}

</table>

<a href="{{ path('_forum_reply', { 'id': topic.getId_topic, 'topic_name': titleForUrl }) }}">Répondre</a>
<span class="paging">{% include "ForumBundle:Default:paging.html.twig" %}</span>



{% endblock %}